//
//  HomeHeader.swift
//  HR
//
//  Created by zhenyu on 17/6/5.
//  Copyright © 2017年 allblue. All rights reserved.
//

import UIKit
import Then

class HomeHeader: UIView {
  
  class ItemView: UIView {
    weak var imageView: UIImageView!
    weak var title: UILabel!
    weak var subtitle: UILabel!
    
    // MARK: - LifeCycle
    override init(frame: CGRect) {
      super.init(frame: frame)
      setViews()
    }
    
    required init?(coder aDecoder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - SetViews
    func setViews() {
      backgroundColor = UIColor.white
      
      imageView = UIImageView(image: #imageLiteral(resourceName: "h_book")).then({ (i) in
        addSubview(i)
        i.snp.makeConstraints({ (make) in
          make.top.equalTo(13)
          make.centerX.equalTo(self)
          make.width.equalTo(85)
          make.height.equalTo(52)
        })
      })
      
      title = UILabel().then({ (l) in
        addSubview(l)
        l.font = HRFont(size: 16)
        l.textColor = Color.font
        l.text = "资质考试"
      }).then({ (l) in
        l.snp.makeConstraints({ (make) in
          make.centerX.equalTo(imageView)
          make.top.equalTo(imageView.snp.bottom).offset(12)
        })
      })
      
      subtitle = UILabel().then({ (l) in
        addSubview(l)
        l.font = HRFont(size: 13)
        l.textColor = Color.lightFont
        l.text = "人事招聘必备技能"
      }).then({ (l) in
        l.snp.makeConstraints({ (make) in
          make.centerX.equalTo(title)
          make.top.equalTo(title.snp.bottom).offset(4)
        })
      })
    }
  }
  

  var itemViews = [ItemView]()
  
  // MARK: - LifeCycle
  override init(frame: CGRect) {
    super.init(frame: frame)
    setViews()
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
  
  // MARK: - SetViews
  func setViews() {
    backgroundColor = Color.back
    
    let width = self.width/3
    let height = self.height
    for i in 0 ..< 3 {
      let item = ItemView(frame: CGRect(x: CGFloat(i) * width, y: 0, width: width, height: height - 12))
      addSubview(item)
    }
  }
}
